package com.quktzhuanka.app.utils;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
import android.view.View;

import com.loopj.android.http.RequestParams;
import com.loopj.android.http.TextHttpResponseHandler;
import com.quktzhuanka.app.common.SPUtils;
import com.quktzhuanka.app.config.Constants;
import com.quktzhuanka.app.https.HttpUtils;
import com.uuch.adlibrary.AdConstant;
import com.uuch.adlibrary.AdManager;
import com.uuch.adlibrary.bean.AdInfo;
import com.youth.banner.transformer.ZoomOutTranformer;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import cz.msebera.android.httpclient.Header;

/**
 * Created by D'Russel on 2017/7/31.
 */

public class JifenUtils {
    // 记录次数    田   2020年7月4日11:08:30
    public static void record_num(final Context context, int cid){
//        RequestParams params = new RequestParams();
//        params.put("cid", cid);
//        params.put("token", SPUtils.getStringData(context, Constants.TOKEN,""));
//        String u = Constants.RECORDNUM;
//        if (cid == 13 || cid == 14){
//            u = Constants.RECORDTOPNUM;
//        }
//        HttpUtils.post(u, params, new TextHttpResponseHandler() {
//            @Override
//            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
//
//            }
//            @Override
//            public void onSuccess(int statusCode, Header[] headers, String responseString) {
//                try {
//                    JSONObject object=new JSONObject(responseString);
//                    if(object.getInt("code")==0) {
////                      T.showShort(context, object.getString("msg")+"赚"+object.getString("data")+"积分");
//                        JifenUtils.tankuang(context);
//                    }
//                } catch (JSONException e) {
//                    e.printStackTrace();
//                }
//            }
//        });
    }


    private static void tankuang(final Context context) {
        final AdInfo adInfo = new AdInfo();
        List<AdInfo> adInfos = new ArrayList<>();
        final AdManager adManager = new AdManager((Activity) context, adInfos);
        adManager.isOverScreen(false);
        adManager.isAnimBackViewTransparent(true);
        adInfo.setActivityImg(Constants.APP_IP + "/Public/static/images/jifen_ok.png");
        adInfo.setUrl("");
        adInfo.setTitle("呵呵哒");
        adInfos.add(adInfo);
        adManager.setOnImageClickListener(new AdManager.OnImageClickListener() {
            @Override
            public void onImageClick(View view, AdInfo advInfo) {
                adManager.dismissAdDialog();
            }
        }).setOnCloseClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (adManager != null) {
                    adManager.dismissAdDialog();
                }
            }
        }, 3000);
        adManager.setOverScreen(true).setPageTransformer(new ZoomOutTranformer()).showAdDialog(AdConstant.ANIM_UP_TO_DOWN);
    }
}